#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QToolBar>
#include <QAction>
#include <QDebug>
#include <QIcon>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // 创建工具栏
    QToolBar* toolBar = new QToolBar();
    this->addToolBar(toolBar);

    // 创建工具
    QAction* open_action = new QAction("打开");
    QAction* close_action = new QAction("关闭");
    toolBar->addAction(open_action);
    toolBar->addAction(close_action);

    // 用图表示
    QIcon open(":/picture/open.png");
    QIcon close(":/picture/close.png");
    open_action->setIcon(open);
    close_action->setIcon(close);

    // 建立连接
    connect(open_action,&QAction::triggered,this,&MainWindow::Open);
    connect(close_action,&QAction::triggered,this,&MainWindow::Close);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::Open()
{
    qDebug() << "打开操作";
}

void MainWindow::Close()
{
    qDebug() << "关闭操作";
}
